package com.shhm.business.controller.business;

import com.shhm.business.dto.request.SubmitOrderReq;
import com.shhm.business.service.business.BusinessProductInfoService;
import com.shhm.common.dto.response.AjaxResultPlus;
import com.shhm.common.entity.common.EvaluationEntity;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author JackZ
 * @version 1.0
 * @description: TODO
 * @date 2025/9/12 下午3:50
 */
@RestController
@RequestMapping("/business")
public class BusinessProductInfoController {
    @Resource
    private BusinessProductInfoService businessProductInfoService;

    @GetMapping("/product/info/{productId}")
    public AjaxResultPlus getProductInfo(@PathVariable Integer productId) {
        return businessProductInfoService.getProductInfo(productId);
    }

    @GetMapping("/seller/product/list/{sellerId}")
    public AjaxResultPlus sellerProductList(@PathVariable Integer sellerId) {
        return businessProductInfoService.sellerProductList(sellerId);
    }

    @GetMapping("/create/order/{productId}")
    public AjaxResultPlus createOrderByProductId(@PathVariable Integer productId) {
        return businessProductInfoService.createOrderByProductId(productId);
    }

    @PostMapping("/submit/order")
    public AjaxResultPlus submitOrder(@RequestBody SubmitOrderReq req) {
        return businessProductInfoService.submitOrder(req);
    }

    @PostMapping("/cancel/order")
    public AjaxResultPlus cancelOrder(@RequestBody SubmitOrderReq req) {
        return businessProductInfoService.cancelOrder(req);
    }

    @GetMapping("/order/info/{orderNum}")
    public AjaxResultPlus getOrderInfo(@PathVariable String orderNum) {
        return businessProductInfoService.getOrderInfo(orderNum);
    }

    @PostMapping("/comment/product")
    public AjaxResultPlus createProductComment(@RequestBody EvaluationEntity entity){
        return businessProductInfoService.createProductComment(entity);
    }
}
